#ifndef __SEMAPHORE_H__
#define __SEMAPHORE_H__

/* include semaphoreh */
/* 4the fundamental datatype */

typedef struct
{
  int	sem_semid;		/* the System V semaphore ID */
  int	sem_magic;		/* magic number if open */
}
sem_t;

#define	SEM_MAGIC	0x45678923

#ifdef	SEM_FAILED
#undef	SEM_FAILED
#endif
#define	SEM_FAILED	((sem_t *)(-1))	/* avoid compiler warnings */

#ifndef	SEMVMX
#define	SEMVMX	32767		/* historical System V max value for sem */
#endif

#define	SVSEM_MODE 0644

sem_t *qsem_open(const char *, int, ... );
int qsem_close(sem_t *);
int qsem_getvalue(sem_t *, int *);
int qsem_post(sem_t *);
int qsem_trywait(sem_t *);
int qsem_unlink(const char *);
int qsem_wait(sem_t *);

#endif  // __SEMAPHORE_H__
